package com.ctec.mapper;

import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface ClickhouseMapper {

    @Select("SELECT name FROM system.columns WHERE table = ${table};")
    public List<String> queryTableFieldsByTableName(String table);

    @Update("ALTER TABLE ${table} ADD COLUMN ${field} ${type};")
    void addColumn(String table, String field,String type);

    @Delete("ALTER TABLE ${table} DROP COLUMN ${field};")
    void deleteColumn(String table, String field);

    @Insert("INSERT INTO ${tableName} FORMAT JSONEachRow ${jsonString}")
    void insertData(String tableName, String jsonString);

    @Select("select * from ${tableName};")
    List<HashMap> queryListByTableName(String tableName);

}
